package com.approval.approvalapp.index.dbsx.wzsp.activity;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.approval.approval.WzspLcAdapter;
import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.WzspXqBean;
import com.approval.approvalapp.index.dbsx.wzsp.adapter.WzxqRvAdapter;
import com.approval.approvalapp.util.base.BaseActivity;
import com.approval.approvalapp.util.net.NetRequsetUtil;
import com.approval.approvalapp.util.net.interfacepac.NetDownResponse;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;

public class WzspxqYbActivity extends BaseActivity {

    @Bind(R.id.back_iv)
    ImageView backIv;
    @Bind(R.id.titleTv1)
    TextView titleTv1;
    @Bind(R.id.name_tv)
    TextView nameTv;
    @Bind(R.id.rv)
    RecyclerView rv;
//    @Bind(R.id.wzfl_tv)
//    TextView wzflTv;
//    @Bind(R.id.slhj_tv)
//    TextView slhjTv;
//    @Bind(R.id.slwz_tv)
//    TextView slwzTv;
    @Bind(R.id.ytsm_tv)
    TextView ytsmTv;
    @Bind(R.id.refuse_tv)
    TextView refuseTv;
    @Bind(R.id.agree_tv)
    TextView agreeTv;
    @Bind(R.id.civ)
    CircleImageView civ;
    @Bind(R.id.colorTv)
    TextView colorTv;
    private String id;
    @Bind(R.id.rv2)
    RecyclerView rv2;


    @Override
    public int getLayoutId() {
        return R.layout.activity_wzspxq_yb;
    }

    @Override
    public void initView() {
        String name = getIntent().getStringExtra("name");
        String state = getIntent().getStringExtra("state");

        if (state.equals("✓ 初审通过")) {

            ColorDrawable colorDrawable = new ColorDrawable(
                    getResources().getColor(R.color.colorAccent));

            civ.setImageDrawable(colorDrawable);
            colorTv.setText("初审通过");
            colorTv.setTextColor(Color.parseColor("#1465FD"));
        }
        if (state.equals("× 初审不通过")){

            ColorDrawable colorDrawable = new ColorDrawable(
                    getResources().getColor(R.color.red));
            civ.setImageDrawable(colorDrawable);
            colorTv.setText("初审不通过");
            colorTv.setTextColor(Color.parseColor("#DE463A"));
        }
        if (state.equals("✓ 终审通过")){
            ColorDrawable colorDrawable = new ColorDrawable(
                    getResources().getColor(R.color.colorAccent));

            civ.setImageDrawable(colorDrawable);
            colorTv.setText("终审通过");
            colorTv.setTextColor(Color.parseColor("#1465FD"));
        }

        if (state.equals("× 终审不通过")){

            ColorDrawable colorDrawable = new ColorDrawable(
                    getResources().getColor(R.color.red));
            civ.setImageDrawable(colorDrawable);
            colorTv.setText("终审不通过");
            colorTv.setTextColor(Color.parseColor("#DE463A"));
        }


        titleTv1.setText(name + "的物资领用");
        nameTv.setText(name);

        id = getIntent().getStringExtra("id");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id", id);
        NetRequsetUtil.getInstance().netRequestPostJson("v1/center/material_already_apply",
                jsonObject.toString(),
                new NetDownResponse() {
                    @Override
                    public void success(String str) {
                        WzspXqBean wzspXqBean = JSON.parseObject(str, WzspXqBean.class);
//                        wzflTv.setText(wzspXqBean.getShow().getType_text());
//                        slhjTv.setText(wzspXqBean.getShow().getContent() + "件");
//                        slwzTv.setText(wzspXqBean.getShow().getMaterial());
                        ytsmTv.setText(wzspXqBean.getShow().getContent());

                        rv.setLayoutManager(new LinearLayoutManager(WzspxqYbActivity.this));
                        WzxqRvAdapter wzxqRvAdapter = new WzxqRvAdapter();
                        wzxqRvAdapter.setListBeanXES(wzspXqBean.getList());
                        rv.setAdapter(wzxqRvAdapter);

                        rv2.setLayoutManager(new LinearLayoutManager(WzspxqYbActivity.this));
                        WzspLcAdapter wzspLcAdapter = new WzspLcAdapter();
                        wzspLcAdapter.setList(wzspXqBean.getProcess());
                        rv2.setAdapter(wzspLcAdapter);
                    }

                    @Override
                    public void errowithresponse(String str) {

                    }

                    @Override
                    public void erro() {

                    }

                    @Override
                    public void finish() {

                    }
                });
    }

    @Override
    public void initData() {

    }

    @OnClick({R.id.refuse_tv, R.id.agree_tv, R.id.back_iv})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.refuse_tv:
                break;
            case R.id.agree_tv:
                break;
            case R.id.back_iv:
                finish();
                break;
        }
    }

}
